﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Data;

namespace Ic.Dao
{
    public interface IDaoSpring
    {
        /// <summary>
        /// 获取错误消息
        /// </summary>
        /// <returns></returns>
        string GetMessage();

        /// <summary>
        /// 存
        /// </summary>
        bool Save<T>(T ab);

        /// <summary>
        /// 批量存储
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="list"></param>
        /// <returns></returns>
        bool BatchSave<T>(IList<T> list);

        /// <summary>
        /// 存
        /// </summary>
        bool Update<T>(T ab);

        /// <summary>
        /// 删除
        /// </summary>
        bool Delete<T>(T ab);

        /// <summary>
        /// 读
        /// </summary>
        T LoadFromId<T>(int id);

        /// <summary>
        /// 获取全部
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <returns></returns>
        IList<T> GetAll<T>() where T : class;

        /// <summary>
        /// 查
        /// </summary>        
        IList<T> SearchByWhere<T>(string where);

        /// <summary>
        /// 查排序
        /// </summary>        
        IList<T> SearchByWhereOrder<T>(string where, string propertyName, bool ascending);

        /// <summary>
        /// 分页
        /// 给出全部参数
        /// </summary>
        /// <param name="tableName">表名</param>
        /// <param name="PrimaryKey">主键</param>
        /// <param name="Columns">列</param>
        /// <param name="pageSize">页大小</param>
        /// <param name="pageIdx">页号</param>
        /// <param name="OrderColumn">排序列</param>
        /// <param name="orderType">true降序 false 升级</param>
        /// <param name="condition">条件</param>
        /// <returns>DataTable</returns>
        DataTable GetPagerByStoreProc<T>(string tableName, string PrimaryKey, string Columns, int pageSize, int pageIdx
            , string OrderColumn, bool orderType, string condition);

        /// <summary>
        /// 重载版本分页
        /// 表名，主键 由元标记(TableInfo)给出
        /// </summary>
        DataTable GetPagerByStoreProc<T>(string Columns, int pageSize, int pageIdx
            , string OrderColumn, bool orderType, string condition);

        /// <summary>
        /// 重载版本分页
        /// 表名，主键，所有列 由元标记(TableInfo)给出
        /// </summary>
        DataTable GetPagerByStoreProc<T>(int pageSize, int pageIdx
            , string OrderColumn, bool orderType, string condition);

        /// <summary>
        /// 获取记录数
        /// </summary>
        int GetRecordCount<T>(string where);

        /// <summary>
        /// 全文检索
        /// </summary>
        /// <typeparam name="T">类型</typeparam>
        /// <param name="query">关键词</param>
        /// <returns></returns>
        IList<T> FullTextSearch<T>(string query);
    }
}
